package com.quanfu.advice;

import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@Aspect
@Component
@Order(10) // 指定一个优先级的值，值越小，优先级越高！越高的前置先执行，后置后执行
public class TxAdvice {

    @Before("com.quanfu.pointcat.MyPointCut.pc()")
    public void before() {
        System.out.println("事务开始");
    }
    @AfterReturning("com.quanfu.pointcat.MyPointCut.pc()")
    public void after() {
        System.out.println("事务结束");
    }
    @AfterThrowing("com.quanfu.pointcat.MyPointCut.pc()")
    public void rollBack() {
        System.out.println("事务回滚");
    }
}
